#
# @lc app=leetcode.cn id=191 lang=python3
#
# [191] 位1的个数
#

# @lc code=start
class Solution:
    def hammingWeight(self, n: int) -> int:
        i, cnt, mask = 0, 0, 1
        while i < 32:
            if (n & mask) != 0:
                cnt += 1
            mask <<= 1
            i += 1
        return cnt
# @lc code=end

